﻿@using KPIS.GERP.Models.ViewModel
@using KPIS.GERP.Models.ICM
@model IEnumerable<MasContactBank>

@{
    Layout = "~/Views/Shared/_EmptyLayout.cshtml";
    ViewBag.Title = "ข้อมูลสมุดเงินฝากธนาคารของผู้ขาย";
    ViewBag.Descr = "ข้อมูลสมุดเงินฝากธนาคารของผู้ขาย";
}

@using (Html.BeginForm("DeleteAllBank", "MasContact", FormMethod.Post, new { id="form" }))
{
    @Html.AntiForgeryToken()
    
    <div class="row-fluid">    
        <div class="block-button-menu-above">
            @Html.ActionLink("เพิ่ม", "CreateBank", new { ConId = Convert.ToInt32(ViewBag.ConId) }
                , new { @class="btn btn-small btn-success button-standard-width", role="button" })
            @Html.ButtonDeleteAll()
        </div>

        @Html.ValidationSummary(true, "", new { @class = "alert alert-error" })

        <div class="row-fluid">
            <div class="table-header span12">
                <div class="span10">
                @ViewBag.Title
                </div>
                <div class="btn-group pull-right">
                    <button data-toggle="dropdown" class="btn btn-small btn-primary dropdown-toggle">
				        Export
				        <i class="icon-angle-down icon-on-right"></i>
			        </button>

			        <ul class="dropdown-menu dropdown-danger" style="min-width:80px;">
				        <li>
					        <a href="#"><i class="icon-file bigger-125"></i>  Word</a>
				        </li>

				        <li>
					        <a href="#"><i class="icon-table bigger-125"></i>  Excel</a>
				        </li>

				        <li>
					        <a href="#"><i class="icon-file-alt bigger-125"></i>  PDF</a>
				        </li>
			        </ul>
                </div>
            </div>
        </div>

        <table id="table" class="table table-striped table-bordered table-hover" aria-describedby="table_info">
            <thead>
                <tr>
                    <th class="center" style="width:50px;">
                        <label>
                            <input type="checkbox" />
                            <span class="lbl"></span>
                        </label>
                    </th>
                    <th style="width:100px;">
                        เลขบัญชีเงินฝาก
                    </th>
                    <th>
                        ชื่อบัญชี
                    </th>
                    <th>
                        ธนาคาร
                    </th>
                    <th>
                        สาขา
                    </th>

                    <th class="center" style="width:80px;">

                    </th>
                </tr>
            </thead>

            <tbody>
                @foreach (var m in Model)
                {
                    <tr>
                        <td class="center">
                            <label>
                                <input type="checkbox" name="deleteIds" value="@(m.ConBankId)" />
                                <span class="lbl"></span>
                            </label>
                        </td>

                        <td>@Html.ActionLink(@m.AccountCode, "DetailsBank", new { Id = m.ConBankId })</td>
                      
                        <td>@Html.DisplayFor(modelItem => m.AccountName)</td>

                        <td>@Html.DisplayFor(modelItem => m.MasBankBranch.Bank.Name)</td>

                        <td>@Html.DisplayFor(modelItem => m.MasBankBranch.BranchName)</td>
                
                        <td class="td-actions">
                            @Html.Partial("_ButtonMenuEachRow", new ExportGrid
                            {
                               Id = m.ConBankId,
                               DetailsUrl = Url.Action("DetailsBank") + "/" + m.ConBankId,
                               EditUrl = Url.Action("EditBank") + "/" + m.ConBankId,
                               DeleteUrl = Url.Action("DeleteBank") + "/" + m.ConBankId
                            })
                        </td>
                    </tr>
                }
            </tbody>
        </table>
    </div>
}

@section scripts {
    
	<script type="text/javascript">
		$(function () {
		    var oTable1 = $('#table').dataTable({
		        "aoColumns": [
                    { "bSortable": false },
                    null,
                    null,
                    null,
                    null,
                    { "bSortable": false }
		        ]
		    });

		    $('table th input:checkbox').on('click', function () {
		        var that = this;
		        $(this).closest('table').find('tr > td:first-child input:checkbox')
				.each(function () {
					this.checked = that.checked;
					$(this).closest('tr').toggleClass('selected');
				});

		    });

		    $('[data-rel=tooltip]').tooltip();

		    $("#form").submit(function () {
		        var currentForm = this;
		        bootbox.confirm(function (result) {
		            var _result = result;
		            if (result) {
		                $.ajax({
		                    url: "DeleteAllBank",
		                    type: "post",
		                    dataType: "json",
		                    data: $(currentForm).serialize(),
		                    success: function (result) {
		                        if (result.success) {
		                            location.reload();
		                        } else {
		                        }
		                    }
		                });
		            }
		        })
		        return false;

		    });

		})

	</script>

}
